<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p id="p">hello world</p>
    <!--window.onload 页面在加载完毕之后才会触发 -->
    <script>
        window.onload = function(){
            var p = document.getElementById("p")
            p.onclick = function(){
                console.log("hello world");
            }
        }
    </script>
</body>
</html>